﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MedicineTracker.ViewModel;

namespace MedicineTracker
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow
    {
        private DataGrid[] _dataGrids = new DataGrid[7];

        public MainWindow()
        {
            InitializeComponent();
            _dataGrids[0] = dataGridAdministations;
            _dataGrids[1] = dataGridDisposals;
            _dataGrids[2] = dataGridMedicines;
            _dataGrids[3] = dataGridPurchases;
            _dataGrids[4] = dataGridReasons;
            _dataGrids[5] = dataGridTreatmentSites;
            _dataGrids[6] = dataGridSuppliers;
        }

        private void tabControlMain_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (tabItemAdministrations.IsSelected) HideDataGrids(0);
            else if (tabItemDisposals.IsSelected) HideDataGrids(1);
            else if (tabItemMedicines.IsSelected) HideDataGrids(2);
            else if (tabItemPurchases.IsSelected) HideDataGrids(3);
            else if (tabItemReasons.IsSelected) HideDataGrids(4);
            else if (tabItemSites.IsSelected) HideDataGrids(5);
            else if (tabItemSuppliers.IsSelected) HideDataGrids(6);

        }

        private void HideDataGrids(int MakeVisible)
        {
            int count = 0;
            foreach(DataGrid thisDG in _dataGrids)
            {
                if (count == MakeVisible) thisDG.Visibility = Visibility.Visible;
                else thisDG.Visibility = Visibility.Collapsed;
                count++;
            }
        }
    }
}
